function [ phi ] = phi( theta, id)
%H=3
load('mainfile1.mat');
alpha=theta(1);
beta=theta(2:6); % <1x5 double>
mu=theta(7:31);  % <1x25 double>
lambda=theta(32);
gamma=theta(33);
chi=theta(34:58);% <1x25 double>
rho=theta(59:63);
c=theta(64);
n=find(consumer_id==id);

for f=1:1:25
    fms= mu(f)+ x(n(1),:)*beta'+alpha*chi(f);
    R=[1:1:f-1 f+1:1:25]; % remainder F\f
    mh=0;
    for l=1:1:10
         RANDOM=randperm(24,3);
         S=[R(RANDOM(1)) R(RANDOM(2)) R(RANDOM(3))]; %% S={g1 g2 g3}where H=3
         
         delta=0;
         for k=1:1:3 
             j=S(k);
             delta=delta+ mu(j)+ x(n(1),:)*beta'+alpha*chi(j);
         end
         m1=log(1+exp(delta+fms));
         m2=log(1+exp(delta));
         mean=m1-m2-(c+x(n(1),:)*rho');
         mh=mh+(exp(mean)/(1+exp(mean)));
    end 
    phi(f)=mh/10;
end 

end
